import 'package:boss/models/takeout_order_list_data.dart';
import 'package:boss/ui/page/takeoutManagement/constant/takeout_status.dart';
import 'package:boss/ui/page/takeoutManagement/util/refund_util.dart';
import 'package:boss/ui/widget/alert/alert.dart';
import 'package:boss/ui/widget/button/outline_radius_button.dart';
import 'package:boss/ui/widget/button/radius_button.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

class AbnormalButtonGroup extends StatelessWidget {
  final TakeoutOrderItem data;

  const AbnormalButtonGroup({Key key, this.data}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(
      children: <Widget>[
////暂不需要
//        Expanded(
//          child: RadiusButton(
//            title: '已完成',
//            onTap: () async {
//              var provider = Provider.of<TakeoutProcessProvider>(
//                context,
//                listen: false,
//              );
//              provider.completeTakeoutOrder(data.takeOutId);
//            },
//          ),
//        ),
//        SizedBox(
//          width: 30.w,
//        ),
        Expanded(
          child: RadiusButton(
            title: '同意退款',
            onTap: () async {


              refundUtilAgree({backDeliveryType}) async{
                RefundUtil.agree(
                  context,
                  takeOutId: data.takeOutId,
                  status: data.systemOrderStatus,
                  price: data.refundMoneyOrder.rebackAmount,
                  backDeliveryType:backDeliveryType,
                );
              }
              //异常单且外卖单询问用户是否退配送费
              if(data.type==TakeoutStatus.TAKEOUT && data.systemOrderStatus == TakeoutStatus.ABNORMA_ORDER){
              //外卖 提示退配送费用
                showAlert(
                  context,
                  content: '是否退配送费?',
                  confirmText: '退',
                  cancelText: '不退',
                  onConfirm: (context) async {
                    Navigator.pop(context);
                    refundUtilAgree(backDeliveryType:1);
                  },
                  onCancel: (context) async {
                    Navigator.pop(context);
                    refundUtilAgree();
                  },
                );

              }else{
                //自提 不提示
                refundUtilAgree();
              }


            },
          ),
        ),
        SizedBox(
          width: 30.w,
        ),
        Expanded(
          child: OutlineRadiusButton(
            title: '拒绝退款',
            onTap: () async {
              RefundUtil.reject(
                context,
                takeOutId: data.takeOutId,
                status: data.systemOrderStatus,
              );
            },
          ),
        ),
      ],
    );
  }
}
